
#ifndef pr_fmt

#include <linux/smp.h>
#include <linux/sched.h>
#undef pr_fmt           /* pr_fmt may be defined by sched.h */
#undef dev_fmt

/* can NOT use "%x" fmt, xxx */
#define dev_fmt(fmt)    KBUILD_MODNAME ": " fmt

/* must define here */
#define PRFMT_FLAG      PF_VERBOSE

#define PF_MFL          (1 << 0)
#define PF_THREAD       (1 << 1)
#define PF_PROCESS      (1 << 2)
#define PF_PID_TID      (1 << 3)
#define PF_VERBOSE      (1 << 30)

#define fmt_enable(x)   (PRFMT_FLAG & PF_##x)

/* 打印模块名、函数名和行号 */
#if !defined(pr_fmt) && fmt_enable(MFL)
#define pr_fmt(fmt) \
    KBUILD_MODNAME ": [%s:%d] " fmt, __func__, __LINE__
#endif

/* 打印线程pid和线程名 */
#if !defined(pr_fmt) && fmt_enable(THREAD)
#define pr_fmt(fmt) \
    "{t%d-%s} " fmt, current->pid, current->comm
#endif

/* 打印进程pid和进程名 */
#if !defined(pr_fmt) && fmt_enable(PROCESS)
#define pr_fmt(fmt) \
    "{p%d-%s} " fmt, \
    current->group_leader->pid, current->group_leader->comm
#endif

/* 打印进程pid和线程pid */
#if !defined(pr_fmt) && fmt_enable(PID_TID)
#define pr_fmt(fmt) \
    "{p%d:t%d} " fmt, current->tgid, current->pid
#endif

#if !defined(pr_fmt) && fmt_enable(VERBOSE)
#define pr_fmt(fmt) \
    KBUILD_MODNAME ": <C%u>{p%d-%s}{t%d-%s}[%s:%d] " fmt, raw_smp_processor_id(), \
    current->group_leader->pid, current->group_leader->comm, \
    current->pid, current->comm, __func__, __LINE__
#endif

#if !defined(pr_fmt) && 0
#define pr_fmt(fmt) 
#endif

#endif
